package com.jeremy.comutils;

import com.jeremy.comutils.domain.ATFileName;
import com.jeremy.comutils.exception.CustomComException;
import com.jeremy.comutils.utils.ATestUtils;

import java.io.IOException;
import java.util.ArrayList;

public class Application {
    private static String jeremyComPort = "COM8";
    private final static int loopTimes = 500000;

    public static void main(String[] args) throws InterruptedException, CustomComException {
        if (args.length > 0) {
            switch (args[0]) {
                case "-help":
                    System.out.println("使用方法：java -jar JeremyComUtils.jar COMX");
                    System.exit(0);
                    break;
                case "-v":
                    System.out.println("JeremyTcpTest V0.1");
                    System.exit(0);
                    break;
                default:
                    System.out.println("成功获取到COM端口号:" + args[0]);
                    jeremyComPort = args[0];
                    break;
            }
        }
        ArrayList<String> ATFilesList = new ArrayList<>();
        //传入加载ATFile名字常量
        ATFilesList.add(ATFileName.INIT);
        //ATFilesList.add(ATFileName.BASE);
        ATFilesList.add(ATFileName.FTP);
        ATFilesList.add(ATFileName.HTTP);
        ATFilesList.add(ATFileName.MQTT);
        //ATFilesList.add(ATFileName.SMS);
        ATFilesList.add(ATFileName.TCPIP);
        ATFilesList.add(ATFileName.TMP);
        try {
            ATestUtils.run(jeremyComPort, ATFilesList, loopTimes);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}